import 'dart:convert';

WithdrawRecordEntity withdrawRecordEntityFromJson(String str) => WithdrawRecordEntity.fromJson(json.decode(str));


class WithdrawRecordEntity {
  int total;
  List<ListWithdrawElement> list;
  int current;

  WithdrawRecordEntity({
    required this.total,
    required this.list,
    required this.current,
  });

  factory WithdrawRecordEntity.fromJson(Map<String, dynamic> json) => WithdrawRecordEntity(
    total: json["total"],
    list: List<ListWithdrawElement>.from(json["list"].map((x) => ListWithdrawElement.fromJson(x))),
    current: json["current"],
  );

}

class ListWithdrawElement {
  int? id;
  DateTime? createdAt;
  DateTime? updatedAt;
  dynamic? deletedAt;
  int? userId;
  int? amount;
  String? type;
  int? status;
  int? userBankId;
  String? rechargeType;
  int? isFirst;
  String? checkNote;
  int? checkAdminId;
  Bank? bank;
  String? rateAmount;

  ListWithdrawElement({
    required this.id,
    required this.createdAt,
    required this.updatedAt,
    required this.deletedAt,
    required this.userId,
    required this.amount,
    required this.type,
    required this.status,
    required this.userBankId,
    required this.rechargeType,
    required this.isFirst,
    required this.checkNote,
    required this.checkAdminId,
    required this.bank,
    required this.rateAmount,
  });

  factory ListWithdrawElement.fromJson(Map<String, dynamic> json) => ListWithdrawElement(
    id: json["id"],
    createdAt: DateTime.parse(json["created_at"]),
    updatedAt: DateTime.parse(json["updated_at"]),
    deletedAt: json["deleted_at"],
    userId: json["user_id"],
    amount: json["amount"],
    type: json["type"],
    status: json["status"],
    userBankId: json["user_bank_id"],
    rechargeType: json["recharge_type"],
    isFirst: json["is_first"],
    checkNote: json["check_note"],
    checkAdminId: json["check_admin_id"],
    bank: Bank.fromJson(json["bank"]),
    rateAmount: json["rate_amount"].toString(),
  );

  String getStatusValue(){
    //状态 0 审核 1成功 2 驳回
    if(status==0){
      return "审核中";
    }else if(status==1){
      return "已通过";
    }else if(status==2){
      return "驳回";
    }else{
      return "";
    }
  }
}

class Bank {
  String fullName;
  String bankName;
  String bankAccount;

  Bank({
    required this.fullName,
    required this.bankName,
    required this.bankAccount,
  });

  factory Bank.fromJson(Map<String, dynamic> json) => Bank(
    fullName: json["full_name"],
    bankName: json["bank_name"],
    bankAccount: json["bank_account"],
  );

  Map<String, dynamic> toJson() => {
    "full_name": fullName,
    "bank_name": bankName,
    "bank_account": bankAccount,
  };

  String bankEndAccount(){
    if(!bankAccount.isEmpty){
      if(bankAccount.length>=4){
        return bankAccount.substring(bankAccount.length-4,bankAccount.length);
      }else{
        return bankAccount;
      }
    }else{
      return "";
    }
  }

}